/*
 * Copyright (C) 2017-2021
 * All rights reserved, Designed By
 * Copyright authorization contact 18814114118
 */
package com.shop.cereshop.app.dao.product;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.app.domain.product.ShopProductVO;
import com.shop.cereshop.app.page.canvas.CanvasProduct;
import com.shop.cereshop.app.page.canvas.CanvasProductNumber;
import com.shop.cereshop.app.page.canvas.CanvasProductSku;
import com.shop.cereshop.app.page.canvas.CanvasProductUsers;
import com.shop.cereshop.app.page.index.Product;
import com.shop.cereshop.app.page.product.*;
import com.shop.cereshop.app.page.productDetail.ShopProductDetailVO;
import com.shop.cereshop.app.param.canvas.CanvasAppProductParam;
import com.shop.cereshop.app.param.index.SearchParam;
import com.shop.cereshop.app.param.index.SearchParamUpdate;
import com.shop.cereshop.app.param.product.PageProductParam;
import com.shop.cereshop.app.param.product.QueryProductListDTO;
import com.shop.cereshop.commons.domain.product.CereShopProduct;
import com.shop.cereshop.commons.domain.product.Classify;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface CereShopProductDAO extends BaseMapper<CereShopProduct> {

    ProductDetailVO getById(@Param("productId") Long productId, @Param("shopId") Long shopId);

    ShopProductDetailVO getProductDetailById(@Param("productId") Long productId, @Param("shopId") Long shopId);

    int deleteByPrimaryKey(Long productId);

    int insertSelective(CereShopProduct record);

    CereShopProduct selectByPrimaryKey(Long productId);

    int updateByPrimaryKeySelective(CereShopProduct record);

    int updateByPrimaryKeyWithBLOBs(CereShopProduct record);

    int updateByPrimaryKey(CereShopProduct record);

    ProductDetail findBySkuId(@Param("skuId") Long skuId, @Param("shopId") Long shopId);

    List<String> findImages(@Param("productId") Long productId);

    List<String> findSkuImages(@Param("productId") Long productId);

    List<Long> findClassifyNumber(@Param("shopId") Long shopId);

    Integer findPayNumber(@Param("skuId") Long skuId);

    ShareProduct findShareProduct(@Param("skuId") Long skuId);

    List<CanvasProduct> getCanvasProducts(CanvasAppProductParam param);

    List<CanvasProduct> getCanvasProducts2(CanvasAppProductParam param);

    List<Classify> findAllClassify();

    List<Classify> findChildsClassify();

    List<Product> findSimilarProducts(@Param("classifyId") Long classifyId);

    void deleteAllSearch(@Param("buyerUserId") Long buyerUserId);

    List<CanvasProduct> getGroupWorkProducts(CanvasAppProductParam param);

    List<CanvasProduct> getSeckillProducts(CanvasAppProductParam param);

    List<CanvasProduct> getDiscountProducts(CanvasAppProductParam param);

    List<Product> getRandomSortProduct(PageProductParam param);

    List<Product> findRandom4ShopProducts(Long shopId);

    int selectFictitiousNumber(Long productId);

    List<Product> findByShopIdAndSkuIdList(@Param("shopId") Long shopId, @Param("skuIdList") List<Long> skuIdList);

    ProductDetail queryProductDetail(Long skuId);

    @MapKey("productId")
    Map<Long, CanvasProductUsers> getProductUsers(CanvasAppProductParam param);

    @MapKey("productId")
    Map<Long, CanvasProductSku> getProductSku(CanvasAppProductParam param);

    @MapKey("productId")
    Map<Long, CanvasProductNumber> getProductNumber(CanvasAppProductParam param);

    List<CanvasProduct> getCanvasActivityRealInfo(CanvasAppProductParam param);

    List<Classify> findClassify(String shopType);

    List<Product> getSearchProductsTitle(SearchParamUpdate param);

    List<Product> getSearchProducts(SearchParam param);

    List<ProductDetailSimple> findProductDetailsByShopId(@Param("shopId") Long shopId, @Param("classifyId2") Long classifyId2, @Param("filter") Long filter, @Param("sort") Long sort, @Param("classifyId3") Long classifyId3, @Param("ids") List<Long> ids);

    //List<Product> selectAllProductToGoodLike();

    List<Long> selectSAllhopId();

    List<CereShopProduct> getProductHootGood();

    List<CereShopProduct> getPriceGoood();

    List<CereShopProduct> selectAllProductWithShopId();

    Long getShopId(Long productId);

    /**
     * 获取商品列表
     * @param dto 查询参数
     * @return 商品列表
     */
    List<ProductListVO> queryProductList(QueryProductListDTO dto);

    /**
     * 获取用户收藏商品列表
     * @param dto 查询参数
     * @return 商品列表
     */
    List<ProductListVO> getUserCollectProductList(QueryProductListDTO dto);

    /**
     * 获取商品热榜列表
     * @param cityCode 城市编码
     * @return 商品列表
     */
    List<ProductListVO> getProductHotList(@Param("cityCode") String cityCode);

    /**
     * 获取店铺商品列表
     * @param shopIds 店铺ID集合
     * @param limit 查询数量
     * @return 商品列表
     */
    List<ShopProductVO> getProductListByShopIds(@Param("shopIds") List<Long> shopIds, @Param("productType") Integer productType, @Param("limit") Long limit);

    /**
     * 获取店铺商品列表
     * @param shopId 店铺ID
     * @param limit 查询数量
     * @return 商品列表
     */
    List<ShopProductVO> getProductListByShopId(@Param("shopId") Long shopId, @Param("limit") Long limit);

}
